package self.niu.com.resume.fragment;

import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.astuetz.PagerSlidingTabStrip;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

import self.niu.com.resume.R;
import self.niu.com.resume.adapter.MyPagerAdapter;
import self.niu.com.resume.ui.ProgressUtils;

/**
 * A simple {@link Fragment} subclass.
 */
public class AbilityFragment extends Fragment {
    private View view;
    @ViewInject(R.id.ability_psdts_tab)
    private PagerSlidingTabStrip tabPsts;
    @ViewInject(R.id.ability_show_viewpager)
    private ViewPager viewPager;
    private String[] titls = {"java篇", "熟悉篇", "熟练篇", "高级篇", "工具篇"};
    private List<Fragment> fragments;
    private MyPagerAdapter adapter;

    public AbilityFragment() {
    }

    public static AbilityFragment getInstance() {
        return new AbilityFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_ability, container, false);
        ViewUtils.inject(this, view);
        ProgressUtils.getInstances().showProgress(getActivity());
        initView();
        return view;
    }

    private void initView() {
        tabPsts.setTextSize(25);
        tabPsts.setTextColor(R.color.white);
        fragments = new ArrayList<>();
        fragments.add(MyAbilitysFragment.getInstance("java"));
        fragments.add(MyAbilitysFragment.getInstance("know"));
        fragments.add(MyAbilitysFragment.getInstance("skilled"));
        fragments.add(MyAbilitysFragment.getInstance("senior"));
        fragments.add(MyAbilitysFragment.getInstance("tool"));
        adapter = new MyPagerAdapter(getChildFragmentManager(), titls, fragments);
        viewPager.setAdapter(adapter);
        tabPsts.setViewPager(viewPager);
    }
}
